Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature#37 add private number #44

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

KarinaDell
Copy link
Contributor

Description

  • What?: We've added an alert for employees#new, this alert is for empty fields and for private number validations. For more background, see ticket Add private number randomly #37 .
  • Why?: These changes help the admin to create an employee, guides the admin through the process.

Testing

None.

Screenshots

image
image

@cfcortes cfcortes linked an issue Nov 24, 2020 that may be closed by this pull request
3 tasks
@KarinaDell KarinaDell added this to the Employees milestone Nov 26, 2020
Copy link

@jaimelr jaimelr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to rebase from master.

@@ -11,6 +11,10 @@ def show

def new
@employee = Employee.new
@private_number = rand(111111..999999)
if Employee.exists?(private_number: @private_number)
@private_number = rand(111111..999999)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the new private number generated has also been already assigned to another Employee?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have validation for that in the model using uniqueness: true

@private_number = rand(111111..999999)
if Employee.exists?(private_number: @private_number)
@private_number = rand(111111..999999)
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are removing changes that you just added in a previous commit. I suggest making all the private number changes in the same commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@@ -21,7 +34,7 @@

<div class="form-group">
<%= label_tag 'private_number', 'Private Number:'%>
<%= form.text_field :private_number, class:'form-control', value: @private_number, disabled: true%>
<%= form.text_field :private_number, class:'form-control'%>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think manually setting the employee number is good. Why not automatically assign an employee number using a generator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We thought about that and we had a lot of trouble and because of time decided to implement it manually.

@@ -14,7 +14,11 @@
*= require_self
*/

.alert-notice{
.alert-notice {
display: none;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in CSS standard is to use two spaces and you are using 4 here.

db/schema.rb Outdated
@@ -33,10 +33,14 @@
t.string "name"
t.string "email"
t.string "position"
<<<<<<< HEAD
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be here. These are Git anotation from an earlier rebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already removed

admin.password_confirmation = "12345"
admin.save

Admin.create(user: 'admin', password_digest: 'admin')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you verify this seeds to be creating valid users?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we had mentorship for that

Copy link

@jaimelr jaimelr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Next time you get a suggestion, try to apply it in the same commit if possible. In this scenario if for some reason you remove the last commit, then your migrations are going to stop working because the comment is in the previous comment.

You can try git commit --amend or an interactive rebase with git rebase -i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add private number randomly
4 participants